from multiprocessing import Pool   # 导入Pool
import time,os


def test(num):
    for i in range(5):   #
        print("这是我-----第%d：进程任务----第%d:子任务，它的进程号码为%d"%(num,i,os.getpid()))
        time.sleep(1)
    return 'abc %d' % num


if __name__=='__main__':
    pool = Pool(2)      # 创造进程池， 并设置进程的数量
    result = []
    for i in range(10):
        print("------------------%d----------------"%(i+1))
        result.append(pool.apply_async(test,(i,)))
    pool.close()  # 关闭进程池， 不让添加进程
    pool.join()
    for res in result:
        print(":::", res.get())
    print("Sub-process(es) done.")
